package com.linkwechat.quartz.util;

import com.linkwechat.common.tenant.TenantContextHolder;
import com.linkwechat.quartz.domain.SysJob;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;

/**
 * 定时任务处理（禁止并发执行）
 * 
 * @author ruoyi
 *
 */
@DisallowConcurrentExecution
public class QuartzDisallowConcurrentExecution extends AbstractQuartzJob
{

    @Override
    protected void before(JobExecutionContext context, SysJob sysJob) {
        super.before(context, sysJob);
        TenantContextHolder.setTenantCode(sysJob.getTenantCode());
    }

    @Override
    protected void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception
    {
        JobInvokeUtil.invokeMethod(sysJob);
    }
}
